home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-05 | 1.9 KB | 108 lines | [TEXT/MSET] |
- \ HashDic class. A dictionary for the assembler.
-
- : SET_OBJECT_CLASS \ ( ^class ^obj -- )
- 6 - reloc! ;
-
- : OBJMOVE { ^obj addr \ ^cl -- }
- ^obj >classCfa -> ^cl
- ^obj obj> \ source
- addr \ dest
- ^obj length: object 8 + \ length
- cmove
- ^cl addr 2+ reloc! ;
-
-
- :class WARRAY super{ indexed-obj } 2 indexed
-
- :m AT: \ ( index -- n )
- inline{ ix w@}
- ^elem2 w@ ;m
-
- :m TO: \ ( n index -- )
- inline{ ix w!}
- ^elem2 w! ;m
-
- :m +TO: \ ( n index -- )
- inline{ ix w+!}
- ^elem2 w+! ;m
-
- :m -TO: \ ( n index -- )
- inline{ ix w-!}
- ^elem2 w-! ;m
-
- :m ^ELEM: \ ( index -- addr )
- inline{ ix}
- ^elem2 ;m
-
- :m FILL: \ ( value -- ) Fills all elements with value.
- idxbase limit 2* bounds
- ?DO dup i w! 2 +LOOP drop ;m
-
- :m CLASSINIT:
- 0 fill: self ;m
-
- ;class
-
-
- 0 value ^LINK
- 0 value HSH
-
- :class HASHDIC super{ wArray }
-
- record
- { uint MASK
- dicaddr STRT
- dicaddr POS
- dicaddr LIM
- }
-
- :m SETMASK: put: mask ;m
-
- :m STRT: get: strt ;m
- :m POS: get: pos ;m
-
- :m ALLOT: \ ( space -- )
- here dup put: strt put: pos
- space reserve
- here put: lim ;m
-
- :m QUERY: { strObj -- ^obj T | -- F }
-
- get: [ strObj ] str255 hash dup -> hsh
- get: mask and ^elem: self -> ^link
- BEGIN
- ^link w@ NIF ( not found ) false EXIT THEN
- ^link Wdisplace dup -> ^link
- 2+ @ hsh =
- IF ( found ) ^link 6 + >obj true EXIT THEN
- AGAIN ;m
-
-
- :m ENTER: { ^obj strObj \ posn len -- b }
- strObj query: self
- IF ( in already - replace old value with new and return false )
- drop ^obj ^link 6 + objmove
- false EXIT
- ELSE
- get: pos -> posn
- ^obj length: object 8 + -> len
- posn len + get: lim > abort" hashDic overflow"
- posn ^link Wdispl!
- 0 posn w! 2 ++> posn
- hsh posn ! 4 ++> posn
- ^obj posn objmove len ++> posn
- posn put: pos true
- THEN ;m
-
- :m DUMP:
- ^base
- get: lim ^base -
- dump ;m
- ;class
-
- endload
-
- \ TEST:
- string s
- 16 hashDic dd 15 setMask: dd 200 allot: dd
-